package org.ehe.finance.payable.domain.bo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.ehe.common.mybatis.core.domain.BaseEntity2;
import org.ehe.finance.payable.domain.ErpFinancePayable;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 应付账款主表Bo
 * @author :zhangnn
 * @className :PayableBo
 * @description: TODO
 * @date 2025-09-02 10:05:35
 */
@Data
@AutoMapper(target = ErpFinancePayable.class,reverseConvertGenerate = false)
public class PayableBo extends BaseEntity2 {
    private Long id;

    @NotBlank(message = "单据编号不能为空")
    @Size(max = 50, message = "单据编号长度不能超过50个字符")
    private String billNo;

    @NotNull(message = "供应商不能为空")
    private Long supplierId;

    @NotNull(message = "单据日期不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate billDate;

    @NotNull(message = "单据类型不能为空")
    @Min(value = 1, message = "单据类型值无效")
    @Max(value = 2, message = "单据类型值无效")
    private Integer billType;

    @Size(max = 50, message = "来源单据号长度不能超过50个字符")
    private String sourceBillNo;

    @NotNull(message = "应付总金额不能为空")
    @DecimalMin(value = "0.00", message = "应付总金额不能为负数")
    @Digits(integer = 16, fraction = 2, message = "应付总金额格式不正确")
    private BigDecimal totalAmount;

    @DecimalMin(value = "0.00", message = "已付款金额不能为负数")
    @Digits(integer = 16, fraction = 2, message = "已付款金额格式不正确")
    private BigDecimal paidAmount;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dueDate;

    @NotNull(message = "币种不能为空")
    private Long currencyId;

    @DecimalMin(value = "0.0001", message = "汇率必须大于0")
    @Digits(integer = 6, fraction = 4, message = "汇率格式不正确")
    private BigDecimal exchangeRate;

    private Long departmentId;
    private Long purchaserId;

    @Size(max = 255, message = "备注长度不能超过255个字符")
    private String remark;

    /**
     * 结算状态
     */
    private Integer settlementStatus;
}
